<template>
  <div class="page-container">
    <div class="in-container">
      <FinancialSearchFrom
        :query="query"
        @reset="reset"
        :tableData="tableData.data"
        ref="financialSearchFromRef"
        @fileOpen="fileOpen"
        :fileUploadVisible="true"
        :isPageJump="pageJump"
        @printFile="printFile"
        :attachmentList="attachmentList"
        @clearTableData="clearTableData"
        @saveData="saveData"
        @onEarch="onEarch"
        :totalCount="totalCount"
        :exchangeRateData="exchangeRateData"
      ></FinancialSearchFrom>
      <div class="btn-box" v-if="!checkIsDisabled">
        <el-button type="primary" @click="openPayableFee">
          {{ doctype == 1 ? '应收费用' : '应付费用' }}
        </el-button>
        <el-button type="primary" @click="deleWriteOff"> 删除销账 </el-button>
      </div>
      <AppPageTable
        stripe
        :data="tableData.data"
        :autostyle="'height: calc(100% - 304px);'"
        :option="tableData.option"
        :isPagination="true"
        @cellClick="cellClick"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column
          width="60"
          label="序号"
          type="index"
          fixed="left"
          align="center"
        >
        </el-table-column>
        <el-table-column label="收/付" width="115" align="center">
          <template #default="scope">
            {{ scope.row.isIncome ? '收款' : '付款' }}
          </template>
        </el-table-column>
        <el-table-column
          prop="doccode"
          width="115"
          label="业务编号"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="blNo" width="115" label="提单号" align="center">
        </el-table-column>
        <el-table-column
          prop="feeName"
          align="center"
          label="费用类型"
          width="115"
        >
        </el-table-column>
        <el-table-column prop="currency" align="center" label="币种" width="80">
        </el-table-column>
        <el-table-column
          prop="totalmoney"
          align="center"
          label="金额"
          width="115"
        >
        </el-table-column>
        <el-table-column
          prop="verificationMoney"
          align="center"
          label="销账金额"
          width="115"
        >
          <template #default="scope">
            <div
              v-if="
                scope.row.index === rowIndex &&
                scope.column.index === colIndex &&
                !checkIsDisabled
              "
            >
              <el-input
                v-model="scope.row.verificationMoney"
                :min="0"
                :max="scope.row.totalmoney"
                size="small"
                :precision="2"
                ref="verificationMoneyRef"
                @change="handleRowChange(scope.row, 'verificationMoney')"
                @blur="loseFocusInput"
                @input="
                  scope.row.verificationMoney = validateNumber(
                    scope.row.verificationMoney
                  )
                "
              >
              </el-input>
            </div>
            <span v-else>{{ scope.row.verificationMoney }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="getUnVerificationMoney"
          align="center"
          label="未销金额"
          width="115"
        >
        </el-table-column>
        <el-table-column
          prop="createTime"
          align="center"
          label="销账日期"
          width="180"
        >
        </el-table-column>
        <el-table-column
          prop="createBy"
          align="center"
          label="销账人"
          width="115"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceCode"
          align="center"
          label="发票号"
          width="115"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceDate"
          align="center"
          label="发票日期"
          width="115"
        >
        </el-table-column>
        <el-table-column prop="feeMemo" align="center" label="备注">
        </el-table-column>
      </AppPageTable>
    </div>
    <FinacialTotal
      style="margin-top: 4px"
      :totalCount="totalCount"
      :isFeeCount="true"
      :doctype="query.doctype"
    ></FinacialTotal>
    <FinacialPayableFee
      ref="payableFeeRef"
      @selectOver="selectOver"
      :doctype="query.doctype"
    ></FinacialPayableFee>
    <!-- 附件上传 -->
    <FInacialFIleUpload
      ref="fInacialFIleUploadRef"
      :attachmentList="attachmentList"
    ></FInacialFIleUpload>
    <!-- 附件下载 -->
    <FinacialPrint ref="finacialPrintRef"></FinacialPrint>
  </div>
</template>

<script>
import { defineComponent } from 'vue'
import FinancialSearchFrom from './FinancialSearchFrom.vue'
import FinacialTotal from './FinacialTotal.vue'
import FinacialPayableFee from './FinacialPayableFee.vue'
import FInacialFIleUpload from './FInacialFIleUpload.vue'
import FinacialPrint from './FinacialPrint.vue'
import AppPageTable, { useTableOption } from '@/components/AppPageTable2'
import dayjs from 'dayjs'
import { ElMessage, ElMessageBox } from 'element-plus'
import { formatNum } from '@/utils/format.ts'
import { validateNumber } from '@/utils/validate.js'
import vueBus from '@/utils/vueBus'
export default defineComponent({
  components: {
    AppPageTable,
    FinancialSearchFrom,
    FinacialTotal,
    FinacialPayableFee,
    FInacialFIleUpload,
    FinacialPrint
  },
  props: {
    doctype: {
      type: Number,
      required: true
    }
  },
  data() {
    return {
      // 查询条件
      query: {
        // 银行卡号
        bankAccount: '',
        // 银行账号名称
        bankAccountName: '',
        // 银行名称
        bankName: '',
        // 可销账金额
        canverificationMoney: '',
        // 审核状态 0草稿 1提交审核  2审核通过  -1驳回
        checkStatus: 0,
        // 付款币种
        currency: '',
        // 付款单号
        doccode: '',
        // 付款日期
        docdate: dayjs().format('YYYY-MM-DD'),
        // 费用单号
        balanceDoccode: '',
        // 收付类型:1 收款,0付款
        doctype: this.doctype,
        // 结算对象代码（左）
        entCode: '',
        // 结算对象名称（右）
        entFullname: '',
        // 结算对象Id
        entId: '',
        //汇率
        exchangeRate: '',
        // 销账币种
        feeCurrency: '',
        // 摘要
        memo: '',
        // 业务员Id
        salesId: '',
        // 业务员名称
        salesName: '',
        // 付款金额
        sumtotalmoney: '',
        // 已销金额
        sumverificationMoney: '',
        // 未销金额
        unVerificationMoney: '',
        //  审核人名称
        checkBy: '',
        // 录入人
        createBy: this.$store.getters['auth/getUser'].nickName,
        // 录入日期
        createTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
      },
      //表格数据
      tableData: {
        data: [],
        option: useTableOption()
      },
      // 合计金额
      totalCount: {
        // 应付合计
        sumtotalmoney: 0,
        // 已销金额
        sumverificationMoney: 0,
        // 未销金额
        unVerificationMoney: 0
      },
      attachmentList: [],
      // 是否是其他页面跳转后打开
      pageJump: false,
      // 缓存跳转过来的查询条件
      cachesSearch: '',
      cacheTableData: [],
      cacheAttachmentList: [],
      // 是否是收付款管理页面跳转
      // isManagerPage: this.$route.query.iscash == "true" ? true : false,
      // 当前选择输入框位置
      colIndex: -1,
      rowIndex: -1,
      exchangeRateData: []
    }
  },
  methods: {
    validateNumber,
    // 重置
    reset() {
      if (this.query.checkStatus == 1 || this.query.checkStatus == 2) {
        ElMessage.success('刷新成功')
        return
      }
      if (this.pageJump) {
        let queryKeys = Object.keys(this.query)
        let hasChangeSearch = false
        let hasChangeTableData = false
        for (const iterator of queryKeys) {
          if (this.cachesSearch[iterator] != this.query[iterator]) {
            console.log(
              iterator +
                '1=' +
                this.cachesSearch[iterator] +
                '&2=' +
                this.query[iterator]
            )
            hasChangeSearch = true
            break
          }
        }
        if (
          JSON.stringify(this.cacheTableData) !=
            JSON.stringify(this.tableData.data) ||
          JSON.stringify(this.cacheAttachmentList) !=
            JSON.stringify(this.attachmentList)
        ) {
          hasChangeTableData = true
        }

        if (hasChangeSearch || hasChangeTableData) {
          ElMessageBox.confirm('您编辑的数据还未保存，确认刷新吗？', '提示', {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.query = { ...JSON.parse(JSON.stringify(this.cachesSearch)) }
            this.tableData.data = JSON.parse(
              JSON.stringify(this.cacheTableData)
            )
            this.$refs.financialSearchFromRef.getSalesman(this.query.salesName)
            this.$refs.financialSearchFromRef.getBusDetail(this.query.entCode)
            this.refreshCount([], 'searchChange')
            ElMessage.success('刷新成功')
          })
        } else {
          ElMessage.success('刷新成功')
        }
      } else {
        this.query = {
          // 银行卡号
          bankAccount: '',
          // 银行账号名称
          bankAccountName: '',
          // 银行名称
          bankName: '',
          // 可销账金额
          canverificationMoney: '',
          // 审核状态 0草稿 1提交审核  2审核通过  -1驳回
          checkStatus: 0,
          // 付款币种
          currency: '',
          // 付款单号
          doccode: '',
          // 付款日期
          docdate: dayjs().format('YYYY-MM-DD'),
          // 费用单号
          balanceDoccode: '',
          // 收付类型:1 收款,0付款
          doctype: this.doctype,
          // 结算对象代码（左）
          entCode: '',
          // 结算对象名称（右）
          entFullname: '',
          // 结算对象Id
          entId: '',
          //汇率
          exchangeRate: '',
          // 销账币种
          feeCurrency: '',
          // 摘要
          memo: '',
          // 业务员Id
          salesId: '',
          // 业务员名称
          salesName: '',
          // 付款金额
          sumtotalmoney: '',
          // 已销金额
          sumverificationMoney: '',
          // 未销金额
          unVerificationMoney: '',
          //  审核人名称
          checkBy: '',
          // 录入人
          createBy: this.$store.getters['auth/getUser'].nickName,
          // 录入日期
          createTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
        }
      }
    },

    // 已销金额同步更新
    handleRowChange(row) {
      // 当前数据还存在未销的金额，输入的金额不能高于该值
      let maxMoney = row.getUnVerificationMoney + row.getVerificationMoney
      row.getVerificationMoney = formatNum(
        row.verificationMoney,
        2,
        0,
        maxMoney
      )
      row.verificationMoney = row.verificationMoney
        ? Number(row.verificationMoney)
        : 0
      if (row.verificationMoney >= parseFloat(maxMoney)) {
        row.verificationMoney = parseFloat(maxMoney)
      }
      row.getUnVerificationMoney = Number(
        (parseFloat(maxMoney) - parseFloat(row.verificationMoney)).toFixed(2)
      )
      // 原始销账金额计算
      // row.getVerificationMoney = formatNum(
      //   row.verificationMoney,
      //   2,
      //   0,
      //   row.totalmoney
      // )
      // row.verificationMoney = row.verificationMoney
      //   ? Number(row.verificationMoney)
      //   : 0
      // if (row.verificationMoney >= parseFloat(row.totalmoney)) {
      //   row.verificationMoney = parseFloat(row.totalmoney)
      // }
      // row.getUnVerificationMoney = Number(
      //   (
      //     parseFloat(row.totalmoney) - parseFloat(row.verificationMoney)
      //   ).toFixed(2)
      // )

      this.refreshCount([], 'searchChange')
    },

    // 输入框失去焦点
    loseFocusInput() {
      this.$refs.financialSearchFromRef.jkl = false
      this.colIndex = -1
      this.rowIndex = -1
    },

    // 单元格点击
    cellClick({ row, column }) {
      // if (this.query.checkStatus == 1 || this.query.checkStatus == 2) {
      //   return;
      // }
      this.colIndex = column.index
      this.rowIndex = row.index
      this.$nextTick(() => {
        this.$refs.verificationMoneyRef.focus()
      })
    },

    // 打开应付费用弹窗==
    openPayableFee() {
      // 查询条件需要先输入销账币种和结算对象
      if (
        !this.$refs.financialSearchFromRef.query.entCode ||
        !this.$refs.financialSearchFromRef.query.feeCurrency
      ) {
        this.$message.warning('请输入结算对象名称和销账币种')
        return
      }
      this.$refs.payableFeeRef.open(
        this.$refs.financialSearchFromRef.query.feeCurrency,
        this.$refs.financialSearchFromRef.query.entId,
        this.$refs.financialSearchFromRef.query.sumtotalmoney,
        0
      )
    },

    // 删除销账
    async deleWriteOff() {
      if (!this.tableData.option.selected.length) {
        this.$message.warning('请选择数据')
        return
      }
      ElMessageBox.confirm('是否确定执行删除操作？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let newArray = []
        this.tableData.data.forEach((t) => {
          if (!this.tableData.option.selected.find((item) => t == item)) {
            newArray.push(t)
          }
        })

        this.tableData.data = newArray
        this.refreshCount([], 'searchChange')
      })
    },

    // 选中的表格数据
    selectOver(selectTableData) {
      let CpoySelectTableData = JSON.parse(JSON.stringify(selectTableData))
      let newArray = []
      CpoySelectTableData.forEach((t) => {
        if (
          !this.tableData.data.find((item) => t.workfeeId == item.workfeeId)
        ) {
          newArray.push(t)
        }
      })
      CpoySelectTableData = newArray
      // 将选中的所有费用数据的未销金额转为已销金额
      CpoySelectTableData.forEach((item) => {
        item.getVerificationMoney = item.getUnVerificationMoney
        item.verificationMoney = item.getUnVerificationMoney
        item.x_verificationMoney = item.verificationMoney
        item.xverificationMoney = Number(
          (item.totalmoney - item.getUnVerificationMoney).toFixed(2)
        )
        item.getUnVerificationMoney = Number(
          (
            item.totalmoney -
            item.verificationMoney -
            item.xverificationMoney
          ).toFixed(2)
        )
        item.x_unVerificationMoney = item.getUnVerificationMoney
      })
      this.refreshCount(CpoySelectTableData, 'searchChange')
    },

    // 重置表格数据
    clearTableData() {
      this.tableData.data = []
      this.tableData.option.selected = []
      this.$refs.financialSearchFromRef.query.canverificationMoney = '0'
      this.$refs.financialSearchFromRef.query.sumverificationMoney = '0'
      this.$refs.financialSearchFromRef.query.unVerificationMoney = '0'
      this.refreshCount([], 'searchChange')
    },
    // 金额计算
    refreshCount(selectTableData, changeType) {
      this.totalCount = {
        // 应付合计
        sumtotalmoney: 0,
        // 已销金额
        sumverificationMoney: 0,
        // 未销金额
        unVerificationMoney: 0
      }
      this.tableData.data = this.mergeAndRemoveDuplicates(
        JSON.parse(JSON.stringify(selectTableData)),
        JSON.parse(JSON.stringify(this.tableData.data))
      )
      // // 销账金额合计
      // let fillTotalVerficationMoney = 0;
      // // 金额合计
      // let fillTotalMoney = 0;
      // let inMoneyTotalOfVer = 0;//收款销账金额
      // let outMoneyTotalOfVer = 0;//付款销账金额
      // let inMoneyTotalOfPrice = 0;//收款金额
      // let outMoneyTotalOfPrice = 0;//付款金额
      for (const iterator of this.tableData.data) {
        const flag = iterator.isIncome == this.query.doctype ? 1 : -1
        // 列表中所有金额的汇总
        this.totalCount.sumtotalmoney += iterator.getTotalmoney
          ? parseFloat(iterator.getTotalmoney) * flag
          : 0
        // 列表中所有销账金额汇总
        this.totalCount.sumverificationMoney += iterator.getVerificationMoney
          ? parseFloat(iterator.getVerificationMoney) * flag
          : 0
        // 列表中所有未销金额汇总
        this.totalCount.unVerificationMoney += iterator.getUnVerificationMoney
          ? parseFloat(iterator.getUnVerificationMoney) * flag
          : 0
        // if (iterator.isIncome == 1) {
        //     inMoneyTotalOfVer += iterator.verificationMoney ? iterator.verificationMoney : 0;
        //     inMoneyTotalOfPrice += iterator.totalmoney ? iterator.totalmoney : 0;
        // } else {
        //     outMoneyTotalOfVer += iterator.verificationMoney ? iterator.verificationMoney : 0;
        //     outMoneyTotalOfPrice += iterator.totalmoney ? iterator.totalmoney : 0;
        // };
      }
      // 当前核销金额合计
      if (changeType) {
        let sumverificationMoney = this.totalCount.sumverificationMoney
          ? this.totalCount.sumverificationMoney.toFixed(0)
          : 0
        this.$refs.financialSearchFromRef.query.sumverificationMoney =
          sumverificationMoney
      }

      var a =
        this.exchangeRateData[this.query.feeCurrency + '' + this.query.doctype]
      var b =
        this.exchangeRateData[this.query.currency + '' + this.query.doctype]

      let num = (b / a) * this.$refs.financialSearchFromRef.query.sumtotalmoney

      if (num >= this.totalCount.sumverificationMoney) {
        this.$refs.financialSearchFromRef.query.canverificationMoney = num
      } else {
        this.$refs.financialSearchFromRef.query.canverificationMoney =
          this.totalCount.sumverificationMoney
      }

      this.$refs.financialSearchFromRef.query.sumverificationMoney =
        this.totalCount.sumverificationMoney
      this.$refs.financialSearchFromRef.query.unVerificationMoney = Math.trunc(
        this.totalCount.sumtotalmoney - this.totalCount.sumverificationMoney
      )
      //this.$refs.financialSearchFromRef.canverificatioChange(this.totalCount.sumverificationMoney.toFixed(2));
      // fillTotalVerficationMoney = outMoneyTotalOfVer - inMoneyTotalOfVer;
      // fillTotalMoney = outMoneyTotalOfPrice - inMoneyTotalOfPrice;
      // if (fillTotalMoney) {
      //     this.$refs.financialSearchFromRef.query.canverificationMoney = fillTotalVerficationMoney.toString();
      //     this.$refs.financialSearchFromRef.query.sumverificationMoney = fillTotalMoney.toString();
      //     this.$refs.financialSearchFromRef.query.unVerificationMoney = fillTotalMoney.toString();
      // } else {
      //     this.$refs.financialSearchFromRef.query.canverificationMoney = fillTotalVerficationMoney.toString();
      //     this.$refs.financialSearchFromRef.query.sumverificationMoney = fillTotalVerficationMoney.toString();
      //     this.$refs.financialSearchFromRef.query.unVerificationMoney = fillTotalVerficationMoney.toString();
      // };
    },

    // 合并数组并去重
    mergeAndRemoveDuplicates(arr1, arr2) {
      let hash = {}
      // 合并两个数组
      let mergedArr = arr1.concat(arr2)
      const newArr = mergedArr.reduce((item, next) => {
        hash[next.workfeeId]
          ? ''
          : (hash[next.workfeeId] = true && item.push(next))
        return item
      }, [])
      return newArr
    },

    // 打开附件上传dailog
    fileOpen() {
      this.$refs.fInacialFIleUploadRef.open()
    },

    // 打开打印报表
    printFile() {
      ElMessage.error('暂无功能')
      return
      this.$refs.finacialPrintRef.open()
    },

    // 填充路由跳转止之后获取的数据进行填充
    fillDataByRouter(searchData) {
      let queryKeys = Object.keys(this.query)
      for (const iterator of queryKeys) {
        if (iterator == 'entId' || iterator == 'salesId') {
          this.query[iterator] =
            searchData.data[iterator] && searchData.data[iterator] != 0
              ? searchData.data[iterator]
              : ''
        } else {
          this.query[iterator] =
            searchData.data[iterator] || searchData.data[iterator] === 0
              ? searchData.data[iterator]
              : ''
        }
      }
      this.checkquery = JSON.parse(JSON.stringify(this.query))
      // this.$refs.financialSearchFromRef.paymentType = (this.query.doctype ? false : true);
      for (const iterator of searchData.data.docCashItemList) {
        iterator.invoiceDate = iterator.invoiceDate
          ? dayjs(iterator.invoiceDate).format('YYYY-MM-DD')
          : ''
        iterator.createtime = iterator.createtime
          ? dayjs(iterator.createtime).format('YYYY-MM-DD HH:mm:ss')
          : ''
      }
      this.tableData.data = searchData.data.docCashItemList
      this.cachesSearch = JSON.parse(JSON.stringify(this.query))
      this.cacheTableData = JSON.parse(JSON.stringify(this.tableData.data))
      this.refreshCount(JSON.parse(JSON.stringify(this.tableData.data)))
      this.attachmentList = searchData.data.attachmentList
      this.cacheAttachmentList = JSON.parse(
        JSON.stringify(searchData.data.attachmentList)
      )

      this.cacheTableData.forEach((item, index) => {
        item.index = index
      })
    },

    // 跳转之后的保存
    payDetailsSave(searchData) {
      this.fillDataByRouter(searchData)
    },

    // 当前页面应收应付下的币种汇率
    async getExchangeRateData() {
      let res = await this.$http.get('/api/base/exchangerate/query', {
        IsIncome: this.query.doctype
      })
      res.content.map((item) => {
        this.exchangeRateData[item.currency + item.isIncome] = item.exchangeRate
      })
    },

    async saveData(query) {
      query.canverificationMoney = query.canverificationMoney
        ? parseFloat(query.canverificationMoney)
        : 0
      query.sumtotalmoney = query.sumtotalmoney
        ? parseFloat(query.sumtotalmoney)
        : 0
      query.exchangeRate = query.exchangeRate
        ? parseFloat(query.exchangeRate)
        : 0
      query.sumverificationMoney = query.sumverificationMoney
        ? parseFloat(query.sumverificationMoney)
        : 0
      query.unVerificationMoney = query.unVerificationMoney
        ? parseFloat(query.unVerificationMoney)
        : 0
      if (this.totalCount.sumverificationMoney < 0) {
        this.$message.error(
          `销账金额为负数，请做${query.doctype ? '收款' : '付款'}管理！`
        )
        return
      }
      if (this.totalCount.sumverificationMoney > query.canverificationMoney) {
        this.$message.error(
          `合计销账金额不能超过${query.doctype ? '收款' : '付款'}可核销金额！`
        )
        return
      }
      query.docCashItemList = this.resetFeeList(this.tableData.data)
      let reqData = {
        ...query,
        id: this.$route.query.id ? this.$route.query.id : 0
      }
      let res = await this.$http.post('/api/doccash/save', reqData)
      if (res.status) {
        let deatailData = await this.$http.get('/api/doccash/get', {
          id: res.data
        })
        if (deatailData.status) {
          // 跳转对应的收付款页面
          if (!(this.isPageJump && this.fileUploadVisible)) {
            if (this.query.doctype == 1) {
              this.$router.push({
                name: 'cashDetail',
                query: {
                  id: res.data,
                  title: '收款详情' + deatailData.data.doccode,
                  iscash: true
                }
              })
              this.onEarch()
            } else {
              this.$router.push({
                name: 'cashOutDetail',
                query: {
                  id: res.data,
                  title: '付款详情' + deatailData.data.doccode,
                  iscash: true
                }
              })
            }
          } else {
            let routeData = {
              path: this.$route.path,
              query: {
                id: res.data,
                title:
                  this.query.doctype == 1
                    ? '收款详情' + deatailData.data.doccode
                    : '付款详情' + deatailData.data.doccode,
                iscash: this.$route.query.iscash
              }
            }
            this.$router.closeAndRefreshTab(routeData)
            this.$emit('payDetailsSave', deatailData)
          }
          ElMessage.success('保存成功')
        } else {
          ElMessage.warning(deatailData.message)
        }
      } else {
        ElMessage.warning(res.message)
      }
    },
    resetFeeList(data) {
      let feeList = []
      for (const iterator of data) {
        let obj = {}
        obj = {
          docId: iterator.docId,
          workfeeId: iterator.workfeeId,
          verificationMoney: iterator.verificationMoney,
          feeMemo: iterator.feeMemo,
          isDeleted: iterator.isDeleted,
          isIncome: iterator.isIncome,
          doccode: iterator.doccode,
          blNo: iterator.blNo,
          feeName: iterator.feeName,
          currency: iterator.currency,
          totalmoney: iterator.totalmoney,
          invoiceCode: iterator.invoiceCode,
          invoiceDate: iterator.invoiceDate,
          balanceDoccode: iterator.balanceDoccode,
          getUnVerificationMoney: iterator.getUnVerificationMoney,
          getTotalmoney: iterator.getTotalmoney,
          getVerificationMoney: iterator.getVerificationMoney
        }
        if (iterator.id) {
          obj['id'] = iterator.id
        }
        feeList.push(obj)
      }
      return feeList
    },
    async onEarch() {
      if (this.$route.query.id) {
        this.pageJump = true
        let searchData = await this.$http.get('/api/doccash/get', {
          id: this.$route.query.id
        })
        // searchData.data.docCashItemList.forEach(item => {
        //     item.x_verificationMoney = item.verificationMoney;
        //     item.x_unVerificationMoney = item.getUnVerificationMoney;
        // });
        if (!searchData.status) {
          this.$message.warning(searchData.message)
          return
        }
        this.$store.dispatch('tab/modifyTabTitle', {
          path: this.$route.fullPath,
          title: this.$route.query.title
        })
        this.fillDataByRouter(searchData)
        this.$refs.financialSearchFromRef.getSalesman(searchData.data.salesName)
        this.$refs.financialSearchFromRef.getBusDetail(searchData.data.entCode)
        this.$refs.financialSearchFromRef.getBankAccount(
          searchData.data.currency
        )
        vueBus.emit('dataForm', searchData)
      }
    }
  },
  watch: {},

  created() {},
  computed: {
    // 审核状态判断是否可编辑
    checkIsDisabled() {
      if (this.query.checkStatus == 1 || this.query.checkStatus == 2) {
        return true
      } else {
        return false
      }
    }
  },

  async mounted() {
    vueBus.emit('doctype', this.query.doctype)
    this.onEarch()
    this.getExchangeRateData()
  }
})
</script>

<style lang="scss" scoped>
.btn-box {
  margin-bottom: 8px;
}
</style>
